package com.android.nodejs.livejs.adapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.android.nodejs.livejs.R;
import com.android.nodejs.livejs.models.User;

public class SearchFriendsAdapter extends ArrayAdapter<User> {
    public SearchFriendsAdapter(Context context, List<User> users) {
        super(context, R.layout.fragment_search_friend_item, users);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        final ViewHolder holder;
        if (row == null) {
            row = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.fragment_search_friend_item, null);
            holder = new ViewHolder();
            //holder.avatar = (ImageView) row.findViewById(R.id.imgAvatar);
            holder.tvFullName = (TextView) row.findViewById(R.id.tvFullName);
            holder.tvLastStatus = (TextView) row.findViewById(R.id.tvLastStatus);
            holder.tvEmail = (TextView) row.findViewById(R.id.tvEmail);
            row.setTag(holder);
        } else {
            holder = (ViewHolder) row.getTag();
        }
        User user = getItem(position);
        holder.tvFullName.setText(user.getFullName());
        holder.tvLastStatus.setText(user.getLastStatus());
        holder.tvEmail.setText(user.getEmail());
        return row;
    }

    private class ViewHolder {
        //ImageView avatar;
        TextView tvFullName, tvLastStatus, tvEmail;
    }

}

